import React from 'react';
import ReactDOM from 'react-dom';
import {message} from 'antd';

import { createHashHistory } from 'History';

import { Router, Route, useRouterHistory } from 'react-router';

import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';

import { Provider } from 'mobx-react';

import { WeaDebugRouteMenu } from 'ecCom';
WeaDebugRouteMenu.defaultProps.showRouteLev = 3;

import FormViewPage from "./components/designer/form/view";
import FormViewStore from "./stores/form/ViewStore";
import "./styles/index.css";
import './styles/formview.css';

const routing = new RouterStore();
const edcFormViewStore = new FormViewStore();

const allStore = window.edcStores = {
    routing,
    edcFormViewStore
};

const browserHistory = useRouterHistory(createHashHistory)({
    queryKey: '_key',
    basename: '/',
});
const history = syncHistoryWithStore(browserHistory, allStore.routing);

window.weaHistory = history;
const Root = () => (
    <Provider {...allStore}>
        <Router history={history}>
            <Route name='root' breadcrumbName='根路由' path='/' component={WeaDebugRouteMenu}>
                <Route path='edc/formview/:key' component={FormViewPage} />
            </Route>
        </Router>
    </Provider>
);

ReactDOM.render(<Root />, document.getElementById('container'));